import { getStore } from '@/util/store'

const dic = {
  test_type: [
    {
      label: '准入考评',
      value: '1'
    },
    {
      label: '周期性考评',
      value: '2'
    }
  ],
  cycle_type: [
    {
      label: '年度',
      value: '1'
    },
    {
      label: '季度',
      value: '2'
    },
    {
      label: '月度',
      value: '3'
    }
  ]
}

export const option = function () {
  return {
    labelWidth: 120,
    emptyBtn: false,
    submitBtn: false,
    detail: ['view'].includes(this.type),
    column: [
      {
        label: '考评申请单号',
        span: 8,
        prop: 'applyCode',
        maxlength: 100,
        disabled: true
      },
      {
        label: '创建人',
        span: 8,
        prop: 'createUser',
        maxlength: 100,
        disabled: true,
        value: getStore({ name: 'userInfo' }).user_name
      },
      {
        label: '创建日期',
        span: 8,
        prop: 'createTime',
        type: 'date',
        format: 'yyyy-MM-dd',
        valueFormat: 'yyyy-MM-dd',
        maxlength: 100,
        disabled: true,
        value: new Date()
      },
      {
        label: '供应商名称',
        span: 8,
        prop: 'supplierName',
        formslot: true,
        rules: [
          {
            required: true,
            message: '请输入供应商名称',
            trigger: 'change'
          }
        ]
      },
      {
        label: '供应商编码',
        span: 8,
        prop: 'supplierCode',
        maxlength: 100,
        disabled: true
      },
      {
        label: '供应商类型',
        span: 8,
        prop: 'supplierCategory',
        maxlength: 100,
        disabled: true
      },
      {
        label: '考评类型',
        span: 8,
        prop: 'testType',
        type: 'radio',
        dicData: dic.test_type,
        value: '1',
        rules: [
          {
            required: true,
            message: '请选择考评类型',
            trigger: 'change'
          }
        ],
        control: (val, form) => {
          if (val === '2') {
            return {
              cycleType: {
                display: true
              },
              year: {
                display: true
              }
            }
          } else {
            return {
              cycleType: {
                display: false
              },
              year: {
                display: false
              }
            }
          }
        }
      },
      {
        label: '负责人',
        span: 8,
        prop: 'leadingPerson',
        maxlength: 100,
        formslot: true
      },
      {
        label: '考评日期',
        span: 8,
        prop: 'testDate',
        type: 'daterange',
        format: 'yyyy-MM-dd',
        valueFormat: 'yyyy-MM-dd',
        startPlaceholder: '考评日期开始',
        endPlaceholder: '考评日期结束',
        rules: [
          {
            required: true,
            message: '请选择考评日期',
            trigger: 'change'
          }
        ]
      },
      {
        label: '周期类型',
        span: 8,
        prop: 'cycleType',
        type: 'select',
        dicData: dic.cycle_type,
        value: '1',
        rules: [
          {
            required: true,
            message: '请选择周期类型',
            trigger: 'change'
          }
        ],
        display: true
      },
      {
        label: '年份',
        span: 8,
        prop: 'year',
        type: 'year',
        rules: [
          {
            required: true,
            message: '请选择年份',
            trigger: 'change'
          }
        ],
        display: true
      },
      {
        label: '备注',
        prop: 'remark',
        type: 'textarea',
        placeholder: '',
        maxlength: 500,
        minRows: 6,
        maxRows: 8,
        span: 24
      }
    ]
  }
}

export const supplierOption = [
  { label: '供应商编码', prop: 'supplierCode' },
  { label: '供应商名称', prop: 'supplierName' },
  { label: '供应商类型', prop: 'supplierCategory' },
  { label: '供应商身份', prop: 'supplierIdentity' }
]
